<?php
$notice_status = array('' => '状态', 1 => '不显示', 2 => "显示");
?>
<div class="SipeiMain_r fr">
    <h2 class="clearfix fonts_18 height45 fontc_444"><?php echo $this->title; ?></h2>
    <div class="clearfix back_bgf border_3 border_c pr30 pt20 pb20 height32 fontc_666">
        <form class="clearfix pb10" action="<?php echo $this->createUrl('index'); ?>" method="get">
            <table width="100%">
                <tbody>
                    <tr>
                        <td width="134" align="right" class="pt10 pr2">所属考试项目：</td>
                        <td width="560" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3"><!--边框-->
                                <span class="fl select_shelter"><!--遮挡默认边框-->
                                    <select class="fl fontc_666" name="exam_id">
                                        <option value="0">请选择</option>
                                        <?php if (!empty($info['examData'])): ?>
                                            <?php foreach ($info['examData'] as $ev): ?>
                                                <option value="<?php echo $ev['exam_id']; ?>" <?php echo (!empty($search['exam_id']) && $search['exam_id'] == $ev['exam_id']) ? 'selected' :'';?>>
                                                    <?php echo $ev['exam_term_name']; ?>
                                                </option>
                                            <?php endforeach; ?>
                                        <?php endif; ?>
                                    </select>
                                </span>
                            </span>
                        </td><!--
                        <td width="103" align="right" class="pt10 pr2">是否显示：</td>
                        <td width="151" class="pt10">
                            <span class="fl standard_select pt5 pr7 pb5 pl3 border_c border_3">边框
                                <span class="fl select_shelter select_shelter2">遮挡默认边框
                                    <select class="fl fontc_666" name="notice_status">
                                        <option value="0">请选择</option>
                                        <option value="2">显示</option>
                                        <option value="1">不显示</option>
                                    </select>
                                </span>
                            </span>
                        </td>
                        -->
                        <td width="126" align="right" class="pt10"><input type="submit" value="查询" class="b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" /></td>
                    </tr>
                </tbody>

            </table>
        </form>
    </div>
    <div class="clearfix back_bgf border_c mt15 pt20 pb20">
        <div class="clearfix pb20 pl30">
            <input type="button" value="新增" onclick="add();"  style="margin-right:30px;" class="fr b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
            <input type="button" value="删除" onclick="delete_all()" class="fl b_a_n border_3 back_bgfb w80 height32 fontc_FFF fonts_12 cursor" />
        </div>
        <form>
            <table class="height40">
                <thead class="back_bgf5 fontc_666">
                    <tr>
                    	<th width="40" align="right" class="m_hr_t m_hr_b pr20"><input type="checkbox" class="checkboxs"></th>
                        <th width="130" align="left" class="m_hr_t m_hr_b pr10">通知标题</th>
                        <th width="170" align="center" class="m_hr_t m_hr_b">通知内容</th>
                        <th width="80" align="center" class="m_hr_t m_hr_b">附件</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">发布人</th>
                        <th width="80" align="center" class="m_hr_t m_hr_b">显示状态</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">通知日期</th>
                        <th width="90" align="center" class="m_hr_t m_hr_b">操作</th>
                    </tr>
                </thead>
                <tbody class="fontc_444">
                    <?php if (!empty($data)): ?>
                        <?php foreach ($data as $value): ?>
                            <tr>
                            	<td align="right" class="m_hr_b pr20"><input type="checkbox" name="deleteAll[]" value="<?php echo $value['notice_id'];?>" class="checkbox"></td>
                                <td align="left" class="m_hr_b pr10">
                                    <a href="<?php echo $this->createUrl('/space/default/info',array('notice_id'=>$value['notice_id'])); ?>"  class="fontc_444">        
                                            <?php echo Func::get_word(strip_tags($value['notice_name']), 20); ?>
                                    </a>
                                </td>
                                <td align="center" class="m_hr_b height20 pt6 pb4" title="<?php echo strip_tags($value['notice_comment']);?>">
                                <?php echo (!empty($value['notice_comment'])) ? Func::get_word(strip_tags($value['notice_comment']), 25) : $value['notice_comment']; ?>
                                </td>
                                <td align="center" class="m_hr_b">
                                    <?php if (!empty($value['file'])): ?>
                                            <img src="/themes/default/images/Sipei/Notice.png">
                                    <?php else: ?>
                                        没有附件
                                    <?php endif; ?>
                                </td>
                                <td align="center" class="m_hr_b"><?php echo $value['username']; ?></td>
                                <td align="center" class="m_hr_b"><?php echo $notice_status[$value['notice_status'] + 1]; ?></td>
                                <td align="center" class="m_hr_b"><?php echo date('Y-m-d', $value['time_created']); ?></td>
                                <td align="center" class="m_hr_b">
                                    <img src="/themes/default/images/Sipei/edit.png" class="mr10 cursor" onclick="update(<?php echo $value['notice_id']; ?>)" title="编辑"/>
                                    <img src="/themes/default/images/Sipei/delate.png" class="cursor" onclick="set_ok(<?php echo $value['notice_id']; ?>,<?php echo $value['notice_status'];?>)" title="删除" />
                                </td>
                            </tr>
                        <?php endforeach; ?>
                    <?php else: ?>
                        <tr>
                            <td colspan="8"><h1 align="center">暂无数据</h1></td>
                        </tr>
                    <?php endif; ?>

                </tbody>
            </table>
        </form>
        <?php $this->renderPartial('//partial/partial_pager', array('pages' => $pages, "url" => $pageUrl)); ?>
    </div>
</div>

<script>
function set_ok(notice_id,is_del) {

	$.dialog.confirm('确定删除吗', function() {
			$.get('/notice/default/delete_all', {notice_id: notice_id}, function(data) {
				location.reload();
	
			});
	});
}

function add() {
	window.location.href = "<?php echo $this->createUrl('add'); ?>";
}

function delete_all(){
	var aa='';
	$("input[name='deleteAll[]']:checkbox:checked").each(function(){
		aa+=$(this).val()+',';
	});
	if(aa == ''){
		$.dialog.alert("请选择要删除条目");
		return false;
	}
	$.dialog.confirm('确定删除所选数据吗', function() {
		aa+=0;

		$.get('/notice/default/delete_all', {notice_id: aa}, function(data) {
			location.reload();

		});
	});
}

function update(notice_id) {
	window.location.href = "<?php echo $this->createUrl('update'); ?>?notice_id=" + notice_id;
	return;
	api = $.dialog({
		id: 'testID2',
		lock: true,
		padding: 0,
		fixed: true,
		title: "添加",
		width: 480,
		height: 430,
		max: false,
		min: false
	});
	$.get('/notice/default/update', {notice_id: notice_id,time:new Date()}, function(html) {
		api.content(html);
	});
}
$(function() {
	$(".checkboxs").click(function() {
		var checkedS = $(this).attr("checked");
		if (checkedS) {
			$(".checkbox").attr("checked", true)
		} else {
			$(".checkbox").removeAttr("checked")
		}
	});

});
</script>